  :root {
    --bg: #0c0f14;
    --surface: #141820;
    --surface2: #1c2230;
    --border: #252d3d;
    --accent: #4fffb0;
    --accent2: #00c4ff;
    --accent3: #ff6b6b;
    --accent4: #ffb86c;
    --text: #e8edf5;
    --muted: #6b7a99;
    --nav-h: 62px;
    --radius: 12px;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
  }

  /* ── NAV ── */
  /* nav {
    position: sticky; top: 0; z-index: 100;
    height: var(--nav-h);
    background: rgba(12,15,20,.9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 clamp(1rem,4vw,2.5rem);
    gap: 1.5rem;
  }
  .logo {
    font-family: 'Space Mono', monospace;
    font-weight: 700; font-size: 1.05rem;
    letter-spacing: -0.02em; color: var(--accent);
    text-decoration: none;
    display: flex; align-items: center; gap: .45rem;
    flex-shrink: 0;
  }
  .logo span { color: var(--text); }
  .nav-links { display: flex; gap: 1.4rem; margin-left: auto; }
  .nav-links a {
    color: var(--muted); text-decoration: none;
    font-size: .875rem; font-weight: 500;
    transition: color .2s;
  }
  .nav-links a:hover { color: var(--text); }*/
  .btn {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--accent); color: #000;
    font-family: 'Space Mono', monospace;
    font-size: .78rem; font-weight: 700;
    padding: .5rem 1.1rem; border-radius: 6px;
    border: none; cursor: pointer; text-decoration: none;
    transition: opacity .15s, transform .12s;
    white-space: nowrap;
  }
  .btn:hover { opacity: .88; transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn.secondary {
    background: transparent; color: var(--accent);
    border: 1.5px solid var(--accent);
  }
  .btn.secondary:hover { background: rgba(79,255,176,.08); }
  .btn.danger {
    background: transparent; color: var(--accent3);
    border: 1.5px solid var(--accent3);
  }
  .btn.danger:hover { background: rgba(255,107,107,.08); }

  /* ── HERO ── */
  .hero {
    text-align: center;
    padding: 4rem clamp(1rem,5vw,2rem) 3rem;
    position: relative; overflow: hidden;
  }
  .hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 70% 55% at 50% 0%, rgba(79,255,176,.07) 0%, transparent 70%);
    pointer-events: none;
  }
  .badge {
    display: inline-flex; align-items: center; gap: .4rem;
    background: rgba(79,255,176,.1); border: 1px solid rgba(79,255,176,.25);
    color: var(--accent); font-family: 'Space Mono', monospace;
    font-size: .72rem; padding: .28rem .8rem; border-radius: 99px;
    margin-bottom: 1.2rem; letter-spacing: .04em;
  }
  .hero h1 {
    font-family: 'Space Mono', monospace;
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 700; line-height: 1.2;
    letter-spacing: -.03em; margin-bottom: .8rem;
  }
  .hero h1 em { font-style: normal; color: var(--accent); }
  .hero p {
    color: var(--muted); max-width: 540px; margin: 0 auto 2rem;
    font-size: 1rem; font-weight: 300;
  }

  /* ── LAYOUT ── */
  .main-wrap {
    max-width: 1160px; margin: 0 auto;
    padding: 0 clamp(1rem,4vw,2rem) 5rem;
  }

  /* ── PANEL ── */
  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .panel-head {
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: .6rem;
    font-family: 'Space Mono', monospace;
    font-size: .78rem; font-weight: 700;
    letter-spacing: .03em; color: var(--muted);
    text-transform: uppercase;
  }
  .panel-head .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
  }
  .panel-head .actions { margin-left: auto; display: flex; gap: .5rem; }
  .panel-body { padding: 1.4rem 1.25rem; }

  /* ── TOP GRID ── */
  .top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
  }
  @media (max-width: 760px) { .top-grid { grid-template-columns: 1fr; } }

  /* ── TEXTAREA ── */
  .text-area-wrap { position: relative; }
  textarea.main-input {
    width: 100%; min-height: 280px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px; color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: .88rem; line-height: 1.7;
    padding: 1rem 1.1rem; resize: vertical;
    outline: none; transition: border-color .2s;
  }
  textarea.main-input:focus { border-color: var(--accent); }
  textarea.main-input::placeholder { color: #3a4460; }

  .char-counter {
    position: absolute; bottom: .6rem; right: .8rem;
    font-family: 'Space Mono', monospace;
    font-size: .68rem; color: var(--muted);
    pointer-events: none;
  }

  /* ── OPTIONS ── */
  .options-row {
    display: flex; flex-wrap: wrap; gap: .75rem;
    align-items: flex-end; margin-top: 1rem;
  }
  .opt-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 130px; }
  .opt-group label {
    font-size: .75rem; color: var(--muted);
    font-weight: 500; letter-spacing: .02em;
  }
  .opt-group input,
  .opt-group select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px; color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: .85rem; padding: .5rem .8rem;
    outline: none; transition: border-color .18s;
    /* -webkit-appearance: none; */
  }
  .opt-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7a99' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    padding-right: 2rem; cursor: pointer;
  }
  .opt-group input:focus,
  .opt-group select:focus { border-color: var(--accent); }

  /* keyword target input */
  .target-input-wrap {
    display: flex; gap: .5rem; align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px; padding: .3rem .5rem .3rem .8rem;
    transition: border-color .18s;
  }
  .target-input-wrap:focus-within { border-color: var(--accent); }
  .target-input-wrap input {
    background: transparent; border: none;
    color: var(--text); font-family: 'DM Sans', sans-serif;
    font-size: .85rem; outline: none; flex: 1; padding: 0;
  }
  .add-kw-btn {
    background: rgba(79,255,176,.15); color: var(--accent);
    border: none; border-radius: 5px;
    font-family: 'Space Mono', monospace;
    font-size: .7rem; font-weight: 700;
    padding: .25rem .6rem; cursor: pointer;
    transition: background .15s;
  }
  .add-kw-btn:hover { background: rgba(79,255,176,.25); }

  .kw-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
  .kw-tag {
    display: inline-flex; align-items: center; gap: .3rem;
    background: rgba(79,255,176,.1); border: 1px solid rgba(79,255,176,.2);
    color: var(--accent); border-radius: 99px;
    font-family: 'Space Mono', monospace;
    font-size: .68rem; padding: .18rem .55rem;
  }
  .kw-tag button {
    background: none; border: none; color: inherit;
    cursor: pointer; font-size: .75rem; line-height: 1;
    padding: 0; opacity: .6;
  }
  .kw-tag button:hover { opacity: 1; }

  /* ── ANALYZE BTN ── */
  .analyze-btn {
    width: 100%; margin-top: 1.2rem;
    background: var(--accent); color: #000;
    font-family: 'Space Mono', monospace;
    font-size: .82rem; font-weight: 700;
    padding: .78rem 1rem; border-radius: 8px;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    transition: opacity .15s, transform .12s;
    letter-spacing: .02em;
  }
  .analyze-btn:hover { opacity: .88; transform: translateY(-1px); }
  .analyze-btn:active { transform: translateY(0); }

  /* ── STATS ROW ── */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  @media (max-width: 600px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1rem;
    position: relative; overflow: hidden;
    transition: border-color .2s;
  }
  .stat-card::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
    background: var(--accent); opacity: 0;
    transition: opacity .3s;
  }
  .stat-card.has-data::after { opacity: 1; }
  .stat-card .stat-label {
    font-size: .72rem; color: var(--muted);
    font-family: 'Space Mono', monospace;
    letter-spacing: .05em; text-transform: uppercase;
    margin-bottom: .4rem;
  }
  .stat-card .stat-val {
    font-family: 'Space Mono', monospace;
    font-size: 1.6rem; font-weight: 700;
    color: var(--text); line-height: 1;
    transition: color .3s;
  }
  .stat-card .stat-sub {
    font-size: .72rem; color: var(--muted);
    margin-top: .25rem;
  }

  /* ── RESULTS GRID ── */
  .results-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
  }
  @media (max-width: 800px) { .results-grid { grid-template-columns: 1fr; } }

  /* ── TABLE ── */
  .kw-table-wrap { overflow-x: auto; }
  table {
    width: 100%; border-collapse: collapse;
    font-size: .82rem;
  }
  thead th {
    font-family: 'Space Mono', monospace;
    font-size: .68rem; letter-spacing: .06em;
    color: var(--muted); text-transform: uppercase;
    text-align: left; padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
    transition: color .15s;
  }
  thead th:hover { color: var(--text); }
  thead th .sort-arrow { opacity: .4; margin-left: .25rem; }
  thead th.sorted { color: var(--accent); }
  thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }
  tbody tr {
    border-bottom: 1px solid rgba(37,45,61,.6);
    transition: background .12s;
  }
  tbody tr:hover { background: rgba(255,255,255,.02); }
  tbody tr:last-child { border-bottom: none; }
  td { padding: .55rem .75rem; vertical-align: middle; }
  td.kw-cell {
    font-family: 'Space Mono', monospace;
    font-size: .75rem; color: var(--text);
  }
  td.kw-cell .kw-highlight {
    background: rgba(79,255,176,.12);
    border: 1px solid rgba(79,255,176,.2);
    color: var(--accent); border-radius: 4px;
    padding: .05rem .3rem;
  }
  td.num-cell {
    font-family: 'Space Mono', monospace;
    font-size: .78rem; color: var(--text);
  }

  /* density bar */
  .bar-cell { min-width: 120px; }
  .density-bar-wrap {
    display: flex; align-items: center; gap: .5rem;
  }
  .density-bar-bg {
    flex: 1; height: 5px; border-radius: 99px;
    background: var(--surface2); overflow: hidden;
  }
  .density-bar-fill {
    height: 100%; border-radius: 99px;
    background: var(--accent);
    transition: width .5s cubic-bezier(.34,1.1,.64,1);
  }
  .density-bar-fill.warn { background: var(--accent4); }
  .density-bar-fill.over { background: var(--accent3); }
  .density-pct {
    font-family: 'Space Mono', monospace;
    font-size: .7rem; min-width: 38px;
    text-align: right;
  }
  .density-pct.warn { color: var(--accent4); }
  .density-pct.over { color: var(--accent3); }
  .density-pct.ok { color: var(--accent); }

  /* status pill */
  .status-pill {
    display: inline-block; font-family: 'Space Mono', monospace;
    font-size: .62rem; font-weight: 700;
    padding: .15rem .45rem; border-radius: 4px;
    letter-spacing: .03em;
  }
  .status-pill.ok { background: rgba(79,255,176,.12); color: var(--accent); }
  .status-pill.low { background: rgba(0,196,255,.12); color: var(--accent2); }
  .status-pill.warn { background: rgba(255,184,108,.12); color: var(--accent4); }
  .status-pill.over { background: rgba(255,107,107,.12); color: var(--accent3); }

  /* ── DONUT CHART ── */
  .donut-wrap {
    display: flex; flex-direction: column;
    align-items: center; gap: 1.2rem;
    padding: .5rem 0;
  }
  .donut-svg-wrap { position: relative; }
  .donut-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
  }
  .donut-center .big { font-family: 'Space Mono', monospace; font-size: 1.5rem; font-weight: 700; }
  .donut-center .small { font-family: 'Space Mono', monospace; font-size: .65rem; color: var(--muted); }
  .donut-legend {
    display: flex; flex-direction: column; gap: .5rem;
    width: 100%;
  }
  .legend-item {
    display: flex; align-items: center; gap: .55rem;
    font-size: .8rem;
  }
  .legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .legend-name { flex: 1; color: var(--muted); font-size: .78rem; }
  .legend-pct {
    font-family: 'Space Mono', monospace;
    font-size: .72rem; color: var(--text);
  }

  /* ── TARGET KW CARD ── */
  .target-results { margin-bottom: 1.5rem; }
  .target-cards { display: flex; flex-wrap: wrap; gap: .75rem; }
  .target-card {
    flex: 1; min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    position: relative; overflow: hidden;
    transition: border-color .2s;
  }
  .target-card.ok { border-color: rgba(79,255,176,.3); }
  .target-card.low { border-color: rgba(0,196,255,.3); }
  .target-card.warn { border-color: rgba(255,184,108,.3); }
  .target-card.over { border-color: rgba(255,107,107,.3); }
  .target-card .tc-kw {
    font-family: 'Space Mono', monospace;
    font-size: .78rem; font-weight: 700; margin-bottom: .5rem;
    color: var(--text);
  }
  .target-card .tc-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
  .target-card .tc-label { font-size: .75rem; color: var(--muted); }
  .target-card .tc-val { font-family: 'Space Mono', monospace; font-size: .8rem; }
  .target-card .tc-bar { height: 4px; background: var(--surface2); border-radius: 99px; margin-top: .5rem; overflow: hidden; }
  .target-card .tc-fill { height: 100%; border-radius: 99px; transition: width .6s; }
  .target-card.ok .tc-fill { background: var(--accent); }
  .target-card.low .tc-fill { background: var(--accent2); }
  .target-card.warn .tc-fill { background: var(--accent4); }
  .target-card.over .tc-fill { background: var(--accent3); }
  .target-card .tc-tip { font-size: .72rem; color: var(--muted); margin-top: .55rem; line-height: 1.4; }

  /* ── EMPTY STATE ── */
  .empty-state {
    text-align: center; padding: 3rem 1rem;
    color: var(--muted);
  }
  .empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
  .empty-state p { font-size: .85rem; font-weight: 300; }

  /* ── FEATURES ── */
  .features-section { margin-top: 4rem; }
  .section-label {
    font-family: 'Space Mono', monospace;
    font-size: .72rem; letter-spacing: .1em;
    color: var(--accent); text-transform: uppercase;
    margin-bottom: .6rem;
  }
  .section-title {
    font-family: 'Space Mono', monospace;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    font-weight: 700; margin-bottom: .6rem;
    letter-spacing: -.02em;
  }
  .section-sub {
    color: var(--muted); font-weight: 300;
    max-width: 420px; margin-bottom: 2.5rem;
  }
  .features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
  }
  .feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.25rem;
    transition: border-color .2s, transform .2s;
    position: relative; overflow: hidden;
  }
  .feature-card::before {
    content: ''; position: absolute; inset: 0; opacity: 0;
    background: radial-gradient(circle at 30% 30%, rgba(79,255,176,.05), transparent 60%);
    transition: opacity .3s;
  }
  .feature-card:hover { border-color: rgba(79,255,176,.3); transform: translateY(-2px); }
  .feature-card:hover::before { opacity: 1; }
  .feature-card .icon { font-size: 1.6rem; margin-bottom: .75rem; display: block; }
  .feature-card h3 {
    font-family: 'Space Mono', monospace;
    font-size: .88rem; font-weight: 700;
    margin-bottom: .4rem; letter-spacing: -.01em;
  }
  .feature-card p { color: var(--muted); font-size: .85rem; font-weight: 300; }

  /* ── FOOTER ── */
  footer {
    border-top: 1px solid var(--border);
    padding: 1.4rem clamp(1rem,4vw,2.5rem);
    text-align: center; color: var(--muted); font-size: .8rem;
    display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap;
  }
  footer a { color: var(--accent); text-decoration: none; }
  footer .sep { color: var(--border); }

  /* ── TOAST ── */
  .toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: var(--accent); color: #000;
    font-family: 'Space Mono', monospace;
    font-size: .75rem; font-weight: 700;
    padding: .6rem 1.2rem; border-radius: 8px;
    transform: translateY(80px); opacity: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none; z-index: 999;
  }
  .toast.show { transform: translateY(0); opacity: 1; }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

  /* hidden */
  .results-section { display: none; }
  .results-section.visible { display: block; }
